<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="房间id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="roomId">
              <a-input v-model="model.roomId" placeholder="请输入房间id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="违规用户id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userId">
              <a-input v-model="model.userId" placeholder="请输入违规用户id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="违规用户昵称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userName">
              <a-input v-model="model.userName" placeholder="请输入违规用户昵称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属会话id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sessionId">
              <a-input v-model="model.sessionId" placeholder="请输入所属会话id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="审核出问题的流" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="streamId">
              <a-input v-model="model.streamId" placeholder="请输入审核出问题的流"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="审核任务id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="requestId">
              <a-input v-model="model.requestId" placeholder="请输入审核任务id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="审核任务媒体类型 1-图片 2-声音" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentType">
              <a-input v-model="model.contentType" placeholder="请输入审核任务媒体类型 1-图片 2-声音"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="审核类型 1、视频 2、音频" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="scene">
              <a-input v-model="model.scene" placeholder="请输入审核类型 1、视频 2、音频"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="命中问题的严重程度 1:PASS， 2: REVIEW，3: REJECT" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="riskLevel">
              <a-input v-model="model.riskLevel" placeholder="请输入命中问题的严重程度 1:PASS， 2: REVIEW，3: REJECT"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="审核命中的违规策略类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="riskType">
              <a-input v-model="model.riskType" placeholder="请输入审核命中的违规策略类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="违规发生的时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="riskTime">
              <a-input v-model="model.riskTime" placeholder="请输入违规发生的时间"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="截图或声音片段地址 http/https" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentUrl">
              <a-input v-model="model.contentUrl" placeholder="请输入截图或声音片段地址 http/https"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="问题详情描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="textDesc">
              <a-input v-model="model.textDesc" placeholder="请输入问题详情描述"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'RoomAuditForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/message.roomaudit/roomAudit/add",
          edit: "/message.roomaudit/roomAudit/edit",
          queryById: "/message.roomaudit/roomAudit/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>